
/****************************************************************************
**
** Copyright (C) 2004-2008 VATATA.com . All rights reserved.
**
** This file is the part of the Miniutil Poject.
** Vatata's miniutil library is lightweight and portable (for linux
** and Windows). The C++ Class Library included Threadpool, Dll danymic loading, 
** General socket application model and tcp server, httpserver/servlet, etc. 
** It is a pratical utility disigned for who don't want learn the Big C++ 
** Developing Platform, such as  Boost or ACE.
**
** This file may be used under the terms of the GNU General Public
** License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file.  Alternatively you may (at
** your option) use any later version of the GNU General Public
** License if such license has been publicly approved by VATATA.com.
** (or its successors, if any) and the Miniutil Project Aministrators. 
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://www.gnu.org/licenses/lgpl.html. If you are unsure which 
** license is appropriate for your use, please review the following 
** information: http://code.google.com/p/miniutil/ or contact 
** http://www.vatata.com.
**
** In addition, as a special exception, VATATA.com, as the sole
** copyright holder for Miniutil Project, grants users of VATATA
** P2P Platform the right to release and package with the related 
** libraries without the source code.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. vatata reserves all rights not expressly
** granted herein.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/


#include "miniutil/address.h"
#include "miniutil/base64.h"
#include "miniutil/buffer.h"
#include "miniutil/data.h"
#include "miniutil/date.h"
#include "miniutil/dir.h"
#include "miniutil/dll.h"
#include "miniutil/socket.h"
#include "minitest/testcase.h"

#include <iostream>

using namespace miniutil;


class classsizechecktest : public testcase
{
public: 
	classsizechecktest()
	{
		themain.tests.push_back( this );
	}

	void PrintOut()
	{
		std::cout<<"###################################################################"<<std::endl;
		std::cout<<"total check:"<<alignment4class.size() + warningclass.size()<<std::endl;
		std::cout<<"-------------------------------------------------------------------"<<std::endl;
		std::cout<<"alignment class:"<<alignment4class.size()<<std::endl;
		for(int i=0; i< (int)alignment4class.size(); i++)
		{
			std::cout<<"\t"<<alignment4class[i].first<<":"<<alignment4class[i].second<<std::endl;
		}
		std::cout<<"-------------------------------------------------------------------"<<std::endl;
		std::cout<<"warning class:"<<warningclass.size()<<std::endl;
		for(int i=0; i< (int)warningclass.size(); i++)
		{
			std::cout<<"\t"<<warningclass[i].first<<":"<<warningclass[i].second<<std::endl;
		}
		std::cout<<"###################################################################"<<std::endl;
	}

	std::vector<std::pair<std::string, int> > alignment4class;
	std::vector<std::pair<std::string, int> > warningclass;

	virtual void test()
	{
#define CHECKSIZE(T) \
	{ \
		int size = sizeof(T); \
		if(size %4 == 0) \
			alignment4class.push_back(std::make_pair(#T, size)); \
		else \
			warningclass.push_back(std::make_pair(#T, size)); \
	}
		
		CHECKSIZE(miniutil::ip4addr);
		CHECKSIZE(miniutil::soaddr);
		CHECKSIZE(miniutil::util::base64);
		CHECKSIZE(miniutil::util::hex);
		CHECKSIZE(miniutil::data::buffer_error);
		CHECKSIZE(miniutil::data::buffer);
		CHECKSIZE(miniutil::data::shared_buffer);
		CHECKSIZE(miniutil::data::storage);
		CHECKSIZE(miniutil::date);
		CHECKSIZE(miniutil::dir);
		CHECKSIZE(miniutil::file);
		CHECKSIZE(miniutil::dll::library);

//		CHECKSIZE(miniutil::net::peer_error);
//		CHECKSIZE(miniutil::net::ioselect);
//		CHECKSIZE(miniutil::net::peer);
//		CHECKSIZE(miniutil::net::peer_ptr);
//		CHECKSIZE(miniutil::net::socket_ptr);
//		CHECKSIZE(miniutil::net::acceptor);

		CHECKSIZE(miniutil::buffer);
		CHECKSIZE(miniutil::socketException);
		CHECKSIZE(miniutil::socket);
		CHECKSIZE(miniutil::serversocket);

		PrintOut();
	}

};

testcase * ptestclasszie = new classsizechecktest();
